<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>{:session('cp.cpsysname')}--商户管理平台</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <meta name="description" content="{:config('webconfig.description');}">
    <meta name="keywords" content="{:config('webconfig.keywords');}">
    <meta name="author" content="runoob">
    <link rel="stylesheet" href="__STATIC_URL__/static/css/bootstrap.css">
    <link rel="stylesheet" type="text/css" href="__STATIC_URL__/static/css/index.css"/>
    <link rel="stylesheet" type="text/css" href="__STATIC_URL__/static/member/css/core1.css?v=3"/>
    <link rel="stylesheet" type="text/css" href="__STATIC_URL__/static/css/getlists.css"/>
    <link rel="stylesheet" type="text/css" href="__STATIC_URL__/static/bootstrap-select/2.0.0-beta1/css/bootstrap-select.css"/>

    <script src="__STATIC_URL__/static/js/jquery-2.1.4.min.js"></script>
    <script src="__STATIC_URL__/static/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <link rel="stylesheet" type="text/css" href="__STATIC_URL__/static/bootstrap-table/bootstrap-table.css"/>
    <script src="__STATIC_URL__/static/bootstrap-table/bootstrap-table.js"></script>
    <script src="__STATIC_URL__/static/bootstrap-table/bootstrap-table-zh-CN.js"></script>
    <script  src="__STATIC_URL__/static/bootstrap-select/2.0.0-beta1/js/bootstrap-select.js"></script>

    <style>
        thead tr th {
            text-align: center;
        }

        tbody tr td {
            text-align: center;
        }
        #selbtn .btn-default,#selbtn .btn-default:hover,#selbtn .btn-default:focus,#selbtn .btn-default:active,#selbtn .btn-default.active,#selbtn .btn-default.focus,#selbtn .btn-default:active,#selbtn .btn-default:focus,#selbtn .btn-default:hover{
             background-color: #fff !important;
            border: 1px solid #e0e0e0 !important;
            color: #4c4c4c !important;
        }
        .bootstrap-select.btn-group .dropdown-menu {
            min-width: 50%;
        }
        #selbtn .dropdown-menu{
            width: 221px;
        }
        #selbtn .dropdown-menu > li > a {
            padding: 0;
        }
        #selbtn .dropdown-menu>li>a {
            line-height: 35px;

        }
    </style>
</head>
<body>
{include file='public/header'/}
<!------------------导航-------------------------->
<section id="content">
    {include file='public/left'/}
    <!--------------------------主要内容区域------------------------------------->
    <div class="content">
        <div class="page-heading mgl15 mgr15">
            <ul class="breadcrumb">
                <li>当前位置是&nbsp;:</li>
                <li>&nbsp;<a href="#">商户管理</a></li>
                <li class="active" style="color: #02b87f;">设备管理</li>

            </ul>
        </div>
        <div class="panel panel-search panel-default mgl15 mgr15">
            <div class="panel-heading">
                <h3 class="panel-title">
                    筛选
                </h3>
            </div>
            <div class="panel-body">
                <form action="" method="get" class="form-horizontal table-search form-search" role="form" id="machform">
                    <div class="col-sm-6 col-md-6 col-lg-4 ">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">商户：</label>
                            <div class="col-sm-9" id="selbtn">

                                <select class="selectpicker show-tick" style="outline: none;width:200px;" data-live-search="true" id="top_mid" name="top_mid">
                                    <option value="" data-name="">请选择商户</option>
                                </select>
                            </div>
                        </div>
                    </div>

                    <div class="col-sm-6 col-md-6 col-lg-4 ">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">状态：</label>
                            <div class="col-sm-9">
                                <select name="status" id="status" class="form-control" required="required">
                                    <option value="">选择状态</option>
                                    <option value="1">未确认</option>
                                    <option value="2">已确认</option>
                                </select>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
            <div class="panel-footer">
                <a href="javascript:;" class="btn btn-primary" onclick="searchform()">查找</a>
                <a href="javascript:;" class="btn btn-default" onclick="clearform()">清空</a>
            </div>
        </div>
        <div class="panel mgl15 mgr15">

            <div class="panel-heading addCharts" style="background:#ededed;">设备列表</div>
            <div class="panel-body">
                <table class="table table-bordered" data-toolbar="#toolbar" id="tablelist">

                </table>
            </div>
        </div>
        {include file='public/footer'/}
    </div>
</section>
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document" style="margin-top:320px;">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">绑定</h4>
            </div>
            <div class="modal-body">
                <div id="mbody">确认信任设备吗？</div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" id="btn">确认</button>
            </div>
        </div>
    </div>
</div>
</body>
<script src="__STATIC_URL__/static/js/commen.js" type="text/javascript" charset="utf-8"></script>
<script src="__STATIC_URL__/static/layer/layer.js" type="text/javascript" charset="utf-8"></script>
<script src="/momachtable.js"></script>
<!-- Modal -->

<script>
    $(window).on('load', function () {
        // 中文重写select 查询为空提示信息
        $('.selectpicker').selectpicker({
            noneSelectedText: '',
            noneResultsText: '',
            liveSearch: true,
            size:7   //设置select高度，同时显示5个值
        });
    });
    $(window).on('load', function () {
        var sid = $("#top_mid").val();
        $('.selectpicker').selectpicker('val', '');
        $('.selectpicker').selectpicker('refresh');
        $.ajax({
            method:'POST',
            url:"{:url('momachtest/getmomachlist')}",
            dataType:'json',
            success: function (res) {
                console.log(123,res);
                var html="<option value='0'>请选择商户</option>";
                console.log(res);
                for (var i = 0; i < res.rows.length; i++) {
                    if (sid == res.rows[i].tid) {
                        html += "<option  value='" + res.rows[i].id + "' selected='selected' data-name='"+res.rows[i].merchant_name+"'>" + res.rows[i].merchant_name + "</option>";
                    } else {
                        html += "<option  value='" + res.rows[i].id + "' data-name='"+res.rows[i].merchant_name+"'>"+ res.rows[i].merchant_name + "</option>";
                    }
                }
                $("#top_mid").html(html);
                $('.selectpicker').selectpicker('refresh');//加载select框选择器
            }
        });
    });



</script>

<script>

    $(function () {
        var type = "getdevicegl";
        var url = "{:url()}";
        getcolumn(type, url, "tablelist")
    });
    function searchform() {
        $("#tablelist" ).bootstrapTable('refresh');
    }
</script>
<script>
    function bangding(obj){
        var id=$(obj).attr("data-id");
        $("#btn").attr("data-id",id);
        var type=$(obj).attr("data-type");
        if(type==1){
            $("#myModalLabel").html("绑定");
            $("#mbody").html("确认信任设备吗？");
        }else if(type==2){
            $("#myModalLabel").html("解绑");
            $("#mbody").html("确认解绑设备吗？");
        }


        $('#myModal').modal('show')
    }
    $(function(){

        $("#btn").click(function(){
            var id = $("#btn").attr("data-id");

            $.ajax({
                url:"{:url('momachtest/momachappstatu')}",
                type:"post",
                data:{id:id},
                success:function(data){
                    console.log(data);
                    $('#myModal').modal('hide')

                    if(data.code==0){
                        layer.msg(data.message,{icon:1,time:1000});
                        setTimeout("window.location.reload()",1000)
                        return false;
                    }else{
                        layer.alert(data.message,{icon:7});
                        return false;
                    }
                }
            })
        })
    })
</script>


</html>
